package com.atguigu.boot.controller;

import com.atguigu.boot.bean.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    // 配置文件中的名字,冒号后面是默认值
    @Value("${person.name:李四}")
    private String name;

    @Autowired
    private Person person;

    // 从环境变量中取值
    @Value("${MAVEN_HOME}")
    private String msg;

    // 操作系统名字
    @Value("${os.name}")
    private String  osName;



    @GetMapping("/")
    public String hello(){
        return person.getClass().toString();
    }
    
    @GetMapping("/person")
    public Person person(){
        return person;
    }

    @GetMapping("/msg")
    public String getMessage(){
        return msg + "==>" + osName;
    }
}
